package com.iot.inclinometer.util;

public class UDPClient extends Thread {

    public final static int TIMEOUT = 3000;
    private String serverIP;
    private int port;

    public UDPClient(String serverIP, int port) {
        this.serverIP = serverIP;
        this.port = port;
    }


    @Override
    public void run() {

//        try {
//            InetAddress serverAddress = InetAddress.getByName(serverIP);
//            DatagramSocket datagramSocket = new DatagramSocket(port, serverAddress);
//            datagramSocket.setSoTimeout(UDPClient.TIMEOUT);
//
//            SendDataDTO sendDataDTO = new SendDataDTO();
//            sendDataDTO.getTranData().addDataItem(new SendDataDTO.DataBodyItemDTO("a","b","n1",1, 2, 3,4,5));
//
//            byte[] data = sendDataDTO.toJson().getBytes();
//            DatagramPacket datagramPacket = new DatagramPacket(data, data.length, serverAddress, port);
//
//            datagramSocket.send(datagramPacket);
//            datagramSocket.close();
//
//        } catch (Exception e) {
//            Log.i("UDPClient", e.getLocalizedMessage());
//
//        }
    }
}
